if [[%1=='i']]  ####################    install
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem sources -l

bundle config mirror.https://rubygems.org https://gems.ruby-china.com
gem sources -c
gem sources -u

echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > /usr/local/rvm/config/db
rvm install "ruby-2.6.5"
rvm use 2.6.5 --default

apt-get install curl openssh-server ca-certificates postfix
#curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash


curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null

#nano /etc/apt/sources.list.d/gitlab_gitlab-ce.list
#append :deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main

apt-get update
apt-get install gitlab-ce

sudo gitlab-ctl reconfigure
service sshd start
service postfix start


elif [[%1=='d']]        ####################    Display
sudo gitlab-ctl status
gitlab-ctl tail


elif [[%1=='r']]        #################### Repair
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
cd /opt/gitlab/embedded/service/gitlab-rails
chmod 777 -R .
bundle install
bundle exec rake assets:precompile RAILS_ENV=production
bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
fi

# 备份：gitlab-rake gitlab:backup:create

# 备份恢复:
# 注意版本一定要一致。
# copy备份文件到了新服务器的/var/opt/gitlab/backups/ 目录下
# 停止相关数据连接服务
# gitlab-ctl stop unicorn
# gitlab-ctl stop sidekiq
# gitlab-rake gitlab:backup:restore BACKUP=1528783710
# 输入几个yes

# 启动所有 gitlab 组件；
gitlab-ctl start
# 停止所有 gitlab 组件；
gitlab-ctl stop 
# 重启所有 gitlab 组件；
gitlab-ctl restart 
# 查看服务状态；
gitlab-ctl status
 # 启动服务；
gitlab-ctl reconfigure
# 修改默认的配置文件；
vim /etc/gitlab/gitlab.rb 
# 检查gitlab；
gitlab-rake gitlab:check SANITIZE=true --trace
# 查看日志；
sudo gitlab-ctl tail 
# 控制台
gitlab-rails console